package com.dataWarehouseOss.rabbitmq.timerTask;

import com.dataWarehouseOss.rabbitmq.util.DelFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;

/**
 * @author ：LiuShihao
 * @date ：Created in 2020/8/12 4:05 下午
 * @desc ：删除两天以前的文件
 */
@Slf4j
@Component
public class DelTwoDaysAgoFileTask {
    private boolean isRun = false;
    public static final String onceEveryTwoDays = "0 0 0 1/2 * ?";
    public static final String onceEveryTwoMinutes = "0 */2 * * * ?";
    @Scheduled(cron=onceEveryTwoDays)
    @Transactional
    public void DelTwoDaysAgoFile() throws IOException {
        log.info("---======开始执行定时任务：删除两天以前的文件======---");
        if (isRun) {
            return;// 正在运行，略过本次
        }
        isRun = true;
        DelFileUtil.deltwoDaysAgoFile();
        DelFileUtil.delFTPFile();
        isRun = false;
    }

}
